using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using WorkflowParticipantsData = Scenario.WorkflowEngine.DataModel.WorkflowParticipantsData;

namespace Scenario.Modeler
{
	/// <summary>
	/// Descrizione di riepilogo per FormAttribute.
	/// </summary>
	public class FormParticipant : System.Windows.Forms.Form
	{
		public WorkflowParticipantsData.XMLRole xmlRole;

		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Button btnSave;
		private System.Windows.Forms.Label lblName;
		private System.Windows.Forms.TextBox txtKey;
		private System.Windows.Forms.TextBox txtDescription;
		private System.Windows.Forms.Label Description;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox txtName;
		/// <summary>
		/// Variabile di progettazione necessaria.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public FormParticipant()
		{
			//
			// Necessario per il supporto di Progettazione Windows Form
			//
			InitializeComponent();

		}

		public FormParticipant(WorkflowParticipantsData.XMLRole role) : this()
		{
			this.txtKey.Text = role.Key;
			this.txtName.Text=role.Name;
			this.txtDescription.Text = role.Description;

			//role.XMLUsers
		}

		/// <summary>
		/// Pulire le risorse in uso.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Codice generato da Progettazione Windows Form
		/// <summary>
		/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
		/// il contenuto del metodo con l'editor di codice.
		/// </summary>
		private void InitializeComponent()
		{
            this.panel2 = new System.Windows.Forms.Panel();
            this.btnCancel = new System.Windows.Forms.Button();
            this.btnSave = new System.Windows.Forms.Button();
            this.lblName = new System.Windows.Forms.Label();
            this.txtKey = new System.Windows.Forms.TextBox();
            this.txtDescription = new System.Windows.Forms.TextBox();
            this.Description = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.txtName = new System.Windows.Forms.TextBox();
            this.panel2.SuspendLayout();
            this.SuspendLayout();
            // 
            // panel2
            // 
            this.panel2.Controls.Add(this.btnCancel);
            this.panel2.Controls.Add(this.btnSave);
            this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel2.Location = new System.Drawing.Point(0, 417);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(392, 42);
            this.panel2.TabIndex = 16;
            // 
            // btnCancel
            // 
            this.btnCancel.Location = new System.Drawing.Point(153, 7);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(60, 35);
            this.btnCancel.TabIndex = 10;
            this.btnCancel.Text = "Cancel";
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // btnSave
            // 
            this.btnSave.Location = new System.Drawing.Point(67, 7);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new System.Drawing.Size(66, 35);
            this.btnSave.TabIndex = 9;
            this.btnSave.Text = "Save";
            this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
            // 
            // lblName
            // 
            this.lblName.Location = new System.Drawing.Point(7, 14);
            this.lblName.Name = "lblName";
            this.lblName.Size = new System.Drawing.Size(86, 14);
            this.lblName.TabIndex = 18;
            this.lblName.Text = "Key";
            // 
            // txtKey
            // 
            this.txtKey.Location = new System.Drawing.Point(7, 28);
            this.txtKey.Name = "txtKey";
            this.txtKey.Size = new System.Drawing.Size(306, 20);
            this.txtKey.TabIndex = 17;
            // 
            // txtDescription
            // 
            this.txtDescription.Location = new System.Drawing.Point(7, 173);
            this.txtDescription.Multiline = true;
            this.txtDescription.Name = "txtDescription";
            this.txtDescription.Size = new System.Drawing.Size(306, 174);
            this.txtDescription.TabIndex = 23;
            // 
            // Description
            // 
            this.Description.Location = new System.Drawing.Point(7, 159);
            this.Description.Name = "Description";
            this.Description.Size = new System.Drawing.Size(80, 14);
            this.Description.TabIndex = 24;
            this.Description.Text = "Value";
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(13, 62);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(87, 14);
            this.label2.TabIndex = 26;
            this.label2.Text = "Name";
            // 
            // txtName
            // 
            this.txtName.Location = new System.Drawing.Point(13, 76);
            this.txtName.Name = "txtName";
            this.txtName.Size = new System.Drawing.Size(307, 20);
            this.txtName.TabIndex = 25;
            // 
            // FormParticipant
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(392, 459);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.txtName);
            this.Controls.Add(this.Description);
            this.Controls.Add(this.txtDescription);
            this.Controls.Add(this.lblName);
            this.Controls.Add(this.txtKey);
            this.Controls.Add(this.panel2);
            this.Name = "FormParticipant";
            this.Text = "Partipant";
            this.panel2.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			xmlRole = new WorkflowParticipantsData.XMLRole();
			xmlRole.Key = this.txtKey.Text;
			xmlRole.Name = this.txtName.Text;
			xmlRole.Description = this.txtDescription.Text;

			this.Close();
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			xmlRole  = null;
			this.Close();
		}
	}
}
